package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmCmcZhuangBei;
import com.ruoyi.web.admin.service.ITdmCmcZhuangBeiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * CMC装备Controller
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/TdmCmcZhuangBei")
public class TdmCmcZhuangBeiController extends BaseController
{
    @Autowired
    private ITdmCmcZhuangBeiService tdmCmcZhuangBeiService;

    /**
     * 查询CMC装备列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcZhuangBei:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmCmcZhuangBei tdmCmcZhuangBei)
    {
        startPage();
        List<TdmCmcZhuangBei> list = tdmCmcZhuangBeiService.selectTdmCmcZhuangBeiList(tdmCmcZhuangBei);
        return getDataTable(list);
    }

    /**
     * 导出CMC装备列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcZhuangBei:export')")
    @Log(title = "CMC装备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmCmcZhuangBei tdmCmcZhuangBei)
    {
        List<TdmCmcZhuangBei> list = tdmCmcZhuangBeiService.selectTdmCmcZhuangBeiList(tdmCmcZhuangBei);
        ExcelUtil<TdmCmcZhuangBei> util = new ExcelUtil<TdmCmcZhuangBei>(TdmCmcZhuangBei.class);
        util.exportExcel(response, list, "CMC装备数据");
    }

    /**
     * 获取CMC装备详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcZhuangBei:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmCmcZhuangBeiService.selectTdmCmcZhuangBeiById(id));
    }

    /**
     * 新增CMC装备
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcZhuangBei:add')")
    @Log(title = "CMC装备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmCmcZhuangBei tdmCmcZhuangBei)
    {
        return toAjax(tdmCmcZhuangBeiService.insertTdmCmcZhuangBei(tdmCmcZhuangBei));
    }

    /**
     * 修改CMC装备
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcZhuangBei:edit')")
    @Log(title = "CMC装备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmCmcZhuangBei tdmCmcZhuangBei)
    {
        return toAjax(tdmCmcZhuangBeiService.updateTdmCmcZhuangBei(tdmCmcZhuangBei));
    }

    /**
     * 删除CMC装备
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcZhuangBei:remove')")
    @Log(title = "CMC装备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmCmcZhuangBeiService.deleteTdmCmcZhuangBeiByIds(ids));
    }
}
